<?php
if($_SERVER["PHP_SELF"] != $CONFIG['phpself'])
exit();
?>
<div class='achdiv'>
<div class='cat'>
<?php echo $ADMIN_SELECTION_TITLE[$Lang]; ?>
</div>
<br/>
<div id="partSuccessOption">
<div class="editpart">
<div class="titleSucces"><?php echo $ADMIN_SUCCESS_CUSTOM_NORMAL[$Lang]; ?></div><br/>
<center><div class = "divProgressionBarSmall"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?page=creation"><?php echo $CREATESUCCESS[$Lang]; ?></a></div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get" name="formSaisie">
<br/><?php echo $SELECTA[$Lang]; ?>
<select name="a">
<option value="-1">----------------SELECT------------------</option>
<?php
$resultCat = mysql_query('SELECT `id`, `name` FROM `achmw_categories`;');
while ($rowCat = mysql_fetch_assoc($resultCat)){
$result = mysql_query('SELECT `id`, `name` FROM `achmw_achievements` WHERE `cat_id`='.$rowCat['id'].';');
if(mysql_num_rows($result)>0)
{
?>
<optgroup label="<?php echo $rowCat['name'];?> (<?php echo mysql_num_rows($result); ?>)">
<?php
while ($row = mysql_fetch_assoc($result)) :
?>
<option value="<?php echo $row['id'];?>"><?php echo $row['name'];?></option>
<?php endwhile; 
}
}?>
</select></center>
<br/>
<script type="text/JavaScript">
	function modifierSubmit()
	{
		document.formSaisie.page.value='modifier';
		if(document.formSaisie.a.options[document.formSaisie.a.options.selectedIndex].value != -1)
			document.formSaisie.submit();
		else
			alert('<?php echo $ADMIN_JAVASCRIPT_ERROR_SUCCESS[$Lang]; ?>');
	}
	function deleteSubmit()
	{
		document.formSaisie.page.value='supprimer';
		if(document.formSaisie.a.options[document.formSaisie.a.options.selectedIndex].value != -1)
			document.formSaisie.submit();
		else
			alert('<?php echo $ADMIN_JAVASCRIPT_ERROR_SUCCESS[$Lang]; ?>');
	}
	function joueurSubmit()
	{
		document.formSaisie.page.value='joueur';
		if(document.formSaisie.a.options[document.formSaisie.a.options.selectedIndex].value != -1)
			document.formSaisie.submit();
		else
			alert('<?php echo $ADMIN_JAVASCRIPT_ERROR_SUCCESS[$Lang]; ?>');
	}
	
	function visualiseSpeSubmit()
	{
		document.formSaisie.page.value='visualise';
		if(document.formSaisie.b.options[document.formSaisie.b.options.selectedIndex].value != -1)
			document.formSaisie.submit();
		else
			alert('<?php echo $ADMIN_JAVASCRIPT_ERROR_SUCCESS[$Lang]; ?>');
	}
	
	function deleteSpeSubmit()
	{
		document.formSaisie.page.value='supprimerSpe';
		if(document.formSaisie.b.options[document.formSaisie.b.options.selectedIndex].value != -1)
			document.formSaisie.submit();
		else
			alert('<?php echo $ADMIN_JAVASCRIPT_ERROR_SUCCESS[$Lang]; ?>');
	}
</script>
<table style="text-align: center; margin-left: auto; margin-right: auto; width: 100%;" border="0"
 cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td style="width: 300px;"><center><div class = "divModifierBarSmall"><a href="javascript:modifierSubmit();"><?php echo $MODIFIERSUCCESS[$Lang]; ?></a></div></center></td>
      <td style="width: 300px;"><center><div class = "divDeleteBarSmall"><a href="javascript:deleteSubmit();"><?php echo $DELETESUCCESS[$Lang]; ?></a></div></center></td>
    </tr>
	<tr>
	 <td colspan="2" rowspan="1" align="center" valign="middle"><center><div class = "divJoueurBarSmall"><a href="javascript:joueurSubmit();"><?php echo $JOUEURSUCCESS[$Lang]; ?></a></div></center></td>
	</tr>
  </tbody>
</table>
<?php
$result = mysql_query('SELECT DISTINCT `admin` FROM `achmw_users_ach_spe`;');
if(mysql_num_rows($result)!=0)
{
?>
<hr/>
<div class="titleSucces"><?php echo $ADMIN_SUCCESS_CUSTOM_GIVE[$Lang]; ?></div><br/>
<center><div class = "divProgressionBarSmall2"><?php echo $SELECTA[$Lang]; ?><br/>
<select name="b">
<option value="-1">----------------SELECT------------------</option>
<?php
$resultCat = mysql_query('SELECT DISTINCT `admin` FROM `achmw_users_ach_spe`;');
while ($rowCat = mysql_fetch_assoc($resultCat)){
$result = mysql_query('SELECT DISTINCT `title`, `id` FROM `achmw_users_ach_spe` WHERE `admin`=\''.$rowCat['admin'].'\' ORDER BY `time` DESC;');
if(mysql_num_rows($result)>0)
{
$resultNameAdmin = mysql_query('SELECT * FROM `achmw_users` WHERE `steamid`=\''.$rowCat['admin'].'\';');
while ($rowNameAdmin = mysql_fetch_assoc($resultNameAdmin)){
	$NameAdminSteamId = $rowNameAdmin['name'];
}
?>
<optgroup label="<?php echo $NameAdminSteamId; ?> (<?php echo mysql_num_rows($result); ?>)">
<?php
while ($row = mysql_fetch_assoc($result)) :
?>
<option value="<?php echo $row['id'];?>"><?php echo $row['title'];?></option>
<?php endwhile; 
}
}?>
</select></div></center><br/>
<table style="text-align: center; margin-left: auto; margin-right: auto; width: 100%;" border="0"
 cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td style="width: 300px;"><center><div class = "divModifierBarSmall"><a href="javascript:visualiseSpeSubmit();"><?php echo $VISUALISERSUCCESS[$Lang]; ?></a></div></center></td>
      <td style="width: 300px;"><center><div class = "divDeleteBarSmall"><a href="javascript:deleteSpeSubmit();"><?php echo $DELETESUCCESS[$Lang]; ?></a></div></center></td>
    </tr>
  </tbody>
</table>
<?php
}
?>
<input type="hidden" name="page" value=""/>
</form>
<br/><br/>
</div>
<br/><br/>
</div>
</div>